package com.d3works.apps.base.web;

import com.d3works.apps.base.db.Print;
import com.d3works.apps.base.service.PrintService;
import com.d3works.exception.D3worksException;
import com.d3works.exception.ResponseMessageType;
import com.d3works.exception.service.TraceBackService;
import com.d3works.inject.Beans;
import com.d3works.rpc.ActionRequest;
import com.d3works.rpc.ActionResponse;

public class PrintController {

  public void generatePDF(ActionRequest request, ActionResponse response) {
    Print print = request.getContext().asType(Print.class);

    try {
      response.setView(Beans.get(PrintService.class).generatePDF(print));
    } catch (D3worksException e) {
      TraceBackService.trace(response, e, ResponseMessageType.ERROR);
    }
  }
}
